export default {
    namespaced: true,
    actions: {
        jiaOdd(context, value) {
            console.log('actions中的 jiaOdd 被调用了');
            if (context.state.sum % 2) {
                context.commit('JIAODD', value)
            }
        },
        jiaWait(context, value) {
            console.log('actions中的 jiaWait 被调用了');
            setTimeout(() => {
                context.commit('JIAWAIT', value)
            }, 500);
        }
    },
    mutations: {
        JIA(state, value) {
            console.log('mutations中的 JIA 被调用了');
            state.sum += value
        },
        JIAN(state, value) {
            console.log('mutations中的 JIAN 被调用了');
            state.sum -= value
        },
        JIAODD(state, value) {
            state.sum += value
        },
        JIAWAIT(state, value) {
            state.sum += value
        },
    },
    state: {
        sum: 0,
        subject: '前端',
        school: '黑马',
    },
    getters: {
        bigSum(state) {
            return state.sum * 10
        }
    },
}
